//
//  ViewController.m
//  图片的裁剪
//
//  Created by xuzhongping on 2016/11/11.
//  Copyright © 2016年 xuzhongping. All rights reserved.
//

#import "ViewController.h"
#import "PPImageCutController.h"


@interface ViewController ()<UIImagePickerControllerDelegate,UINavigationControllerDelegate>
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    
}

- (IBAction)swithImage:(id)sender {
    
    UIImagePickerController *pickVc = [[UIImagePickerController alloc]init];
    pickVc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    pickVc.delegate = self;
    
    [self presentViewController:pickVc animated:YES completion:nil];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
    UIImage *image = info[UIImagePickerControllerOriginalImage];
    
    _imageView.image = image;
    
    image = nil;
    [picker dismissViewControllerAnimated:YES completion:nil];
}
- (IBAction)editImageClick:(id)sender {
    if (!_imageView.image) return;
    PPImageCutController *cutVc = [[PPImageCutController alloc]init];
    cutVc.cutImage = _imageView.image;
    
    [self presentViewController:cutVc animated:YES completion:nil];
}
@end
